package com.news.cloud.jpa.domain;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.OneToMany;
import java.sql.Timestamp;
import java.util.List;

/**
 * Created by hiephn on 2014/06/28.
 */
@Entity
public class User extends NameDescPersistable {
    private static final long serialVersionUID = 1L;

    @Column(nullable = false, length = 128)
    private String password;
    @Column(nullable = false, length = 45)
    private String fullName;
    @Column
    private Timestamp birthday;
    @Column(length = 20)
    private String phone;
    @Column(length = 256)
    private String fbAccessToken;
    @Column(length = 256)
    private String ggAccessToken;
    @Column(length = 64)
    private String fbUpdatedTime;
    @Column(length = 64)
    private String ggUpdatedTime;
    @Column(length = 128, nullable = false)
    private String email;
    @Column
    private Gender gender;
    @Column(length = 512)
    private String imgUrl;

    @ManyToMany(fetch = FetchType.LAZY)
    @JoinTable(name = "user_role",
        joinColumns = @JoinColumn(name = "user_id"),
        inverseJoinColumns = @JoinColumn(name = "role_id"))
    private List<Role> roles;
    @OneToMany(fetch = FetchType.LAZY, mappedBy = "user")
    private List<Hobby> hobbies;

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public String getFullName() {
        return fullName;
    }

    public void setFullName(String fullName) {
        this.fullName = fullName;
    }

    public Timestamp getBirthday() {
        return birthday;
    }

    public void setBirthday(Timestamp birthday) {
        this.birthday = birthday;
    }

    public String getPhone() {
        return phone;
    }

    public String getFbAccessToken() {
        return fbAccessToken;
    }

    public void setFbAccessToken(String fbAccessToken) {
        this.fbAccessToken = fbAccessToken;
    }

    public String getGgAccessToken() {
        return ggAccessToken;
    }

    public void setGgAccessToken(String ggAccessToken) {
        this.ggAccessToken = ggAccessToken;
    }

    public String getFbUpdatedTime() {
        return fbUpdatedTime;
    }

    public void setFbUpdatedTime(String fbUpdatedTime) {
        this.fbUpdatedTime = fbUpdatedTime;
    }

    public String getGgUpdatedTime() {
        return ggUpdatedTime;
    }

    public void setGgUpdatedTime(String ggUpdatedTime) {
        this.ggUpdatedTime = ggUpdatedTime;
    }

    public String getEmail() {
        return email;
    }

    public void setEmail(String email) {
        this.email = email;
    }

    public Gender getGender() {
        return gender;
    }

    public void setGender(Gender gender) {
        this.gender = gender;
    }

    public String getImgUrl() {
        return imgUrl;
    }

    public void setImgUrl(String imgUrl) {
        this.imgUrl = imgUrl;
    }

    public void setPhone(String phone) {
        this.phone = phone;
    }

    public List<Role> getRoles() {
        return roles;
    }

    public void setRoles(List<Role> roles) {
        this.roles = roles;
    }

    public List<Hobby> getHobbies() {
        return hobbies;
    }

    public void setHobbies(List<Hobby> hobbies) {
        this.hobbies = hobbies;
    }
}
